<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="js/jquery-1.8.3.js" ></script>
<script type="text/javascript">
   $(function(){
	   $("input:first").blur(function(){
		   $.post("CheckNameServlet",{userName:$("input:first").val()},callback);
	   });
   });
   function callback(data){
	   if(data=="true"){
		   $("#msg").html("");
		   $("#msg").html("用户名已经存在").css("color","red");
		   $(":submit").attr("disabled",true);
	   }else{
		   $("#msg").html("");
		   $("#msg").html("用户名可以使用").css("color","black");
		   $(":submit").attr("disabled",false);
	   }
   }
</script>
</head>
<body>
   <form action="RegisterServlet" method="post">
           用户名<input name="username" type="text" /><span id="msg"></span><br/>
           密&nbsp;码<input name="userpwd" type="password" /><br/>
           <input type="submit" value="注册">
   </form>
</body>
</html>